import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

export const constantRouterMap = [
	{
		path: '/',
		name: 'home',
		component: resolve => require(['@/views/homepage'], resolve),
		meta: { title: '首页', icon: 'home', noCache: true },
	},
	{
		path: '/:module',
		name: 'module',
		component: resolve => require(['@/views/modules'], resolve),
		meta: { name: "", title: "", noCache: true },
	},
];


const router = new Router({
	mode: 'hash',
	base: process.env.VUE_APP_BASE_PATH,
	scrollBehavior: () => ({ y: 0 }),
	routes: constantRouterMap
});

router.beforeEach((route, from, next) => {
	let nextRoute = null;

	document.title = `${route.meta.title} - ${process.env.VUE_APP_TITLE}`;
	nextRoute ? next(nextRoute) : next();
});

export default router